<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>阜安街道智慧党建平台登录</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="assets/css/amazeui.datatables.min.css" />
    <link rel="stylesheet" href="assets/css/app.css">
    <script src="assets/js/jquery.min.js"></script>
    <style>
        
        body{
            background-color: #f11110 !important;
        }
        .login_form{
            background-color: red;
            border-radius: 10px;
            box-shadow: 0 0 15px #3c3333;
        }
        .login_form input{
            width: 270px;
            border-radius: 5px !important;
            outline: none;
            border: 0;
            height: 35px;
            background: white !important;
            padding-left: 10px !important;
        }
        .login_form label{
            color: white !important;
            padding-right: 20px;
        }
        .login_form input::placeholder{
            font-size: 16px;
            color: #888383 !important;
            
        }
        #login{
            width: 280px;
            height: 38px;
            float: right;
        }
    </style>
</head>

<body data-type="login" >
    <script src="assets/js/theme.js"></script>
    <div class="am-g tpl-g">
        <!-- 风格切换 -->

        <div class="tpl-login">
            <div class="tpl-login-content">
                <div class="tpl-login-logo">
                </div>
                <form class="am-form tpl-form-line-form am-form-horizontal login_form">
                    <div class="am-form-group">
                        <label  class="am-u-sm-2 am-form-label">账号</label>
                        <div class="am-u-sm-10">
                            <input type="test" id="username" placeholder="请输入账号">
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label  class="am-u-sm-2 am-form-label">密码</label>
                        <div class="am-u-sm-10">
                            <input type="password" id="password" placeholder="请输入密码">
                        </div>
                    </div>
            
                    <div class="am-form-group">
                        <button type="button" id="login" class="am-btn am-btn-danger  am-btn-block tpl-btn-bg-color-danger  tpl-login-btn"></button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script src="assets/js/amazeui.min.js"></script>
    <script src="assets/js/app.js"></script>
<script>
    $(function(){
        sessionStorage.clear();
    });
     $(document).keyup(function () {
         if (event.keyCode === 13)
             document.getElementById("login").click();
     });
        $("#login").click(function () {
            let username = $("#username").val();
            let password = $("#password").val();
            $.ajax({
                type: 'post',
                url: testurl + 'users/login',
                contentType: "application/json",
                data: JSON.stringify({
                    "username":username,
                    "password":password
                }),
                success:function(data){
                    console.log(data)
                    if (data.success === true){
                        sessionStorage.setItem("username",username);
                        sessionStorage.setItem("realname",data.obj.userInfo.name);
                        sessionStorage.setItem("password",password);
                        sessionStorage.setItem("user_id",data.obj.userInfo.id);
                        sessionStorage.setItem("phone",data.obj.userInfo.contacts_phone);
                        sessionStorage.setItem("company_name",data.obj.userInfo.company_name);
                        sessionStorage.setItem("token",data.obj.token);
                        sessionStorage.setItem("role",data.obj.role);
                        sessionStorage.setItem("post_id",data.obj.userInfo.post_id);
                        sessionStorage.setItem("companyId",data.obj.userInfo.companyId);
                        sessionStorage.setItem("authList",data.obj.authList);
                        window.location.href = "index.html"
                    } else {
                        alert(data.message);
                    }
                }
            })
        });
</script>

</body>

</html>